<?php

class IndexController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */
        $this->view->headMeta()->appendHttpEquiv("Content-Type", "text/html; charset=utf-8");
        $this->view->headLink()->appendStylesheet(HOST_PATH . 'public/css/reset.css');
        $this->view->headLink()->offsetSetStylesheet("2", HOST_PATH . 'public/css/compact.css');
        $this->view->headLink()->offsetSetStylesheet("3", HOST_PATH . 'public/css/lightbox.css');
        $this->view->headLink()->offsetSetStylesheet("4", HOST_PATH . 'public/css/nivo-slider.css');
        $this->view->headLink()->offsetSetStylesheet("5", HOST_PATH . 'public/css/default.css');

        $this->view->headScript()->appendFile(HOST_PATH . "public/js/jquery-1.7.1.min.js");
        $this->view->headScript()->offsetSetFile("2", HOST_PATH . "public/js/jquery.all.v5.js");
        $this->view->headScript()->offsetSetFile("3", HOST_PATH . "public/js/jquery.ezpz_tooltip.js");
        $this->view->headScript()->offsetSetFile("4", HOST_PATH . "public/js/original.js");
        $this->view->headScript()->offsetSetFile("5", HOST_PATH . "public/js/jquery.validate.js");
        $this->view->headScript()->offsetSetFile("6", HOST_PATH . "public/js/messages_vi.js");

        $option = array('layout' => 'layout1',
            'layoutPath' => APPLICATION_PATH . "/layouts/scripts");
        Zend_Layout::startMVC($option);
        $theloai1 = new Default_Model_Theloai1();
        $list_tl1 = $theloai1->getAll();
        $theloai2 = new Default_Model_Theloai2();
        $list_tl2 = array();
        foreach ($list_tl1 as $tl1) {
            $list_tl2[] = $theloai2->getAllTheLoai2($tl1['matl1']);
        }
        $tinh = new Default_Model_Tinh();
        $poster = new Default_Model_Poster();
        $this->view->tinh = $tinh->getAll();
        $this->view->poster = $poster->getAll();
        $this->view->theloai1 = $list_tl1;
        $this->view->theloai2 = $list_tl2;
    }

    public function indexAction() {
        // action body
        $sach = new Default_Model_Sach();
        $this->view->numPageKM = $sach->page4KhuyenMai();
        $this->view->numPageKhac = $sach->page4Khac();
        $this->view->numPageBC = $sach->page4BanChay();
        $this->view->banchay = $sach->getSach4BanChay(1);
        $this->view->khuyenmai = $sach->getSach4KhuyenMai(1);
        $this->view->khac = $sach->getSach4Khac(1);
    }

    public function khuyenmaiAction() {
        // action body
    }

    public function khacAction() {
        // action body
    }

    public function banchayAction() {
        // action body
    }

    public function ajax4khuyenmaiAction() {
        // action body
        $page = $this->_request->getParam('page');
        $sach = new Default_Model_Sach();
        $this->view->sach = $sach->getSach4KhuyenMai($page);
        $this->_helper->viewRenderer('ajax4sach');
        $this->_helper->layout()->disableLayout();
    }

    public function ajax4khacAction() {
        // action body
        $page = $this->_request->getParam('page');
        $sach = new Default_Model_Sach();
        $this->view->sach = $sach->getSach4Khac($page);
        $this->_helper->viewRenderer('ajax4sach');
        $this->_helper->layout()->disableLayout();
    }

    public function ajax4banchayAction() {
        // action body
        $page = $this->_request->getParam('page');
        $sach = new Default_Model_Sach();
        $this->view->sach = $sach->getSach4BanChay($page);
        $this->_helper->viewRenderer('ajax4sach');
        $this->_helper->layout()->disableLayout();
    }

}

